# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=wcslib
pkgver=8.2.1
pkgrel=1
pkgdesc="A C library that implements the 'World Coordinate System' (WCS) standard in FITS"
arch=(loong64 x86_64)
url='https://www.atnf.csiro.au/people/Mark.Calabretta/WCS/'
license=(GPL3)
depends=(cfitsio
         glibc)
makedepends=(gcc-fortran)
source=(ftp://ftp.atnf.csiro.au/pub/software/$pkgname/$pkgname-$pkgver.tar.bz2)
sha256sums=('b666c79568fc0cf16b6d585ff3d560ae5e472c3b1125a90ccc8038f8e84aca19')

build() {
  cd $pkgname-$pkgver

  export CFLAGS+=" -ffat-lto-objects"
  ./configure --prefix=/usr --without-pgplot
  make
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install

  # Fix wrong permissions
  chmod g=rx,-s "$pkgdir"/usr/{bin/,/lib/{,pkgconfig},share/man/man1/}
  chmod -s "$pkgdir"/usr/{include/wcslib-$pkgver/,share/doc/wcslib-$pkgver/{,html/}}
}
